package com.csit.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.csit.bean.Pager;
import com.csit.dao.CustomerDao;
import com.csit.entity.Customer;
import com.csit.service.CustomerService;
import com.csit.util.ListAndJsonUtil;

@Service
public class CustomerServiceImpl extends BaseServiceImpl<Customer, Integer> implements CustomerService {
	@Resource
	private CustomerDao customerDao;
	@Resource
	public void setBaseDao(CustomerDao customerDao) {
		super.setBaseDao(customerDao);
	}

	public String queryCustomer(Integer pageNumber, Integer pageSize,Customer customer) {
		Pager pager = new Pager(pageNumber, pageSize);
		try {
			pager = customerDao.queryCustomer(pager, customer);
			String[] propertiesName = {"customerID","customerCode","customerName","sex","birthday","character","company",
							"roleName","telephone","address","note","customerTypeName","customerTypeID","customerSourceName","customerSourceID"};
			String jsonArray = ListAndJsonUtil.getJSONString(pager.getList(), propertiesName, pager.getTotalCount());
			return jsonArray;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
